//
//  BaseTextField.m
//  TenMinDemo
//
//  Created by Shawn Li on 2021/3/13.
//  Copyright © 2021 CYXiang. All rights reserved.
//

#import "BaseTextField.h"
#import <objc/runtime.h>

@implementation BaseTextField

- (void)awakeFromNib{
    [super awakeFromNib];
    self.placeholderFont = [UIFont boldSystemFontOfSize:15];
}

-(void)changePlaceholder{
    Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel");
    UILabel *placeholderLabel = object_getIvar(self, ivar);
    placeholderLabel.textColor = _placeholderColor;
    placeholderLabel.font = _placeholderFont;
}
-(void)setPlaceholderColor:(UIColor *)placeholderColor{
    _placeholderColor = placeholderColor;
    [self changePlaceholder];
}
-(void)setPlaceholder:(NSString *)placeholder{
    [super setPlaceholder:placeholder];
    [self changePlaceholder];
}
-(void)setPlaceholderFont:(UIFont *)placeholderFont{
    _placeholderFont = placeholderFont;
    [self changePlaceholder];
}
@end
